package com.sbtr.business.classify.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.sbtr.business.classify.entity.AlgoCondition;
import com.sbtr.business.classify.dto.AlgoConditionDto;

import com.sbtr.business.classify.service.AlgoConditionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sbtr.business.classify.mapper.AlgoConditionMapper;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sbtr.common.PageDto;
import com.sbtr.util.PageDtoUtils;
import org.springframework.transaction.annotation.Transactional;

/**
 * 裁剪条件 Service接口实现类
 *
 * @author dgl
 * @since  2023-09-01
 */
@Transactional
@Service
public class AlgoConditionServiceImpl extends ServiceImpl<AlgoConditionMapper,AlgoCondition> implements AlgoConditionService {

    @Autowired
    AlgoConditionMapper algoConditionMapper;

    @Override
    public PageDto<AlgoCondition> pageList(AlgoConditionDto algoConditionDto) {

        IPage<AlgoCondition> page = new Page<>();
        page.setSize(algoConditionDto.getPageSize());
        page.setCurrent(algoConditionDto.getPage());
        page = algoConditionMapper.selectPages(page, BeanUtil.beanToMap(algoConditionDto));
        PageDto<AlgoCondition> r = PageDtoUtils.getPageDtoByIPage(page, AlgoCondition.class);

        return r;
    }
}

